From 75ffac9dd596242121db2449cb24598223b71b62 Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc" Date: Fri, 22 Mar 2024 16:21:14 -0500 Subject: [PATCH] Fix flake8 style problems and provide a core exception example --- .../src/pgwui_TEMPLATE/exceptions.py.mak | 35 +++++++++++++++---- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/src/pgwui_develop/TEMPLATE/src/pgwui_TEMPLATE/exceptions.py.mak b/src/pgwui_develop/TEMPLATE/src/pgwui_TEMPLATE/exceptions.py.mak index 70fd33e..f1aa67b 100644 --- a/src/pgwui_develop/TEMPLATE/src/pgwui_TEMPLATE/exceptions.py.mak +++ b/src/pgwui_develop/TEMPLATE/src/pgwui_TEMPLATE/exceptions.py.mak @@ -1,4 +1,4 @@ -# Copyright (C) 2020 The Meme Factory, Inc. http://www.karlpinc.com/ +# Copyright (C) 2020, 2024 The Meme Factory, Inc. http://www.karlpinc.com/ # This file is part of ${component}. # @@ -23,18 +23,39 @@ from pgwui_common import exceptions as common_ex from pgwui_core import exceptions as core_ex -# PGWUI setting related exceptions +# PGWUI setting and user-supplied value related exceptions -class Error(common_ex.SetupError): +class ExampleSetupError(common_ex.SetupError): pass -class ExampleOnOffAskError(SetupError): +class ExampleOnOffAskError(ExampleSetupError): def __init__(self, value): super().__init__( - 'The "pgwui:${component}:example_on_off_ask" PGWUI setting ' - ' must be "on", "off", "ask", or not present') + ('The "pgwui:${component}:example_on_off_ask" PGWUI setting ' + ' must be "on", "off", "ask", or not present'), + descr=f'Got: ({value})') -class ExampleDetailedError(SetupError): + +class ExampleDetailedError(ExampleSetupError): def __init__(self, e, descr='', detail=''): super().__init__('Detailed error', descr=descr, detail=detail) + + +# Data error related exception + +class ExampleTooManyRowsError(core_ex.DataLineError): + ''' + Module exception rasied while line-by-line processing the uploaded + data. + + lineno The line number + e The error message + descr More description of the error + detail Extra HTML describing the error + data The uploaded data + ''' + def __init__(self, lineno, e, descr='', detail='', data=''): + if descr is None: + descr = 'Too many rows of uploaded data' + super().__init__(e, lineno, descr, detail, data) -- 2.34.1